package uba.ing2.subite.domain;

import java.util.Date;

import uba.ing2.subite.util.DateUtil;

/**
 * Representa una factura paga.
 */
public class PaidInvoice implements Invoice {
	private Date paymentDate;
	private PaymentCard paymentCard;
	private Invoice invoice;

	public PaidInvoice(Date paymentDate, PaymentCard paymentCard, Invoice invoice) {
		this.paymentDate = paymentDate;
		this.paymentCard = paymentCard;
		this.invoice = invoice;
	}

	@Override
	public PaymentTerminal paymentTerminal() {
		return invoice.paymentTerminal();
	}

	@Override
	public Number total() {
		return invoice.total();
	}
	
	public Invoice invoice() {
		return invoice;
	}

	public Date paymentDate() {
		return paymentDate;
	}
	
	public PaymentCard paymentCard() {
		return paymentCard;
	}

	@Override
	public String shortDescription() {
		return invoice.shortDescription();
	}

	public boolean appliesTo(LegalEntity legalEntity, Date date) {
		return paymentTerminal().legalEntity().equals(legalEntity)
			&& DateUtil.equalsWithoutTime(paymentDate(), date);
	}
}
